package com.bw.documents.preview

import android.os.Bundle
import android.util.Log
import android.view.LayoutInflater
import androidx.appcompat.app.AppCompatActivity
import com.alibaba.android.arouter.facade.annotation.Route
import com.bw.documents.databinding.ActivityMusicBinding
import tv.danmaku.ijk.media.player.IjkMediaPlayer

@Route(path = "/documents/MusicActivity")
class MusicActivity : AppCompatActivity(){

    private val v : ActivityMusicBinding by lazy { ActivityMusicBinding.inflate(LayoutInflater.from(this)) }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(v.root)
        IjkMediaPlayer.loadLibrariesOnce(null)
        IjkMediaPlayer.native_profileBegin("libijkplayer.so")
        val path = intent.extras!!.getString("path")
        v.musicPage.titleTv.text = "音频预览"
        Log.e("ZXY","path:"+path)
        v.musicPage.backImg.setOnClickListener { finish() }
        v.musicView.setVideoPath(path)
        v.musicView.start()
    }

    override fun onStop() {
        super.onStop()
        v.musicView.stopPlayback()
        v.musicView.release(true)
        IjkMediaPlayer.native_profileEnd()
    }
}